<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();
	String orgId = user.getCurOrgId();
	String userName = user.getUserrelName();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>药具出库管理</title>

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerComboBox.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerResizable.js"></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';
var org_id = '<%=orgId%>';
var userName = '<%=userName%>';

_jsonObj.classname = "com.wxtf.platform.main.contraceptives.TmaOutcomeAction";
_jsonObj.methodname = "queryPage";

var manager;//出库表格
var chakan;
var detail;//明细
var mingxi = [];
var tmaod = 0;
var chukubianhao = "00000";
var grid;
$(function(){
	manager = $("#manager").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',enabledSort:false,pageSize:100,
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,async:false,
		columns: [
			{ display: 'tmaom_id', name: 'tmaom_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '出库编号', name: 'tmaom_code', width: 200, align: 'left', render: function(record, index, value, oth){
					return "<a href='javascript:Detail(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}
			},
			{ display: '出库日期', name: 'tmaom_time', width: 150, align: 'left' },
			{ display: '类型', name: 'tmaom_type', width:  100, align: 'left' },
			{ display: '申领单位', name: 'org_id2', width:  100, align: 'left' ,render: function(record, index, value, oth){
					return value==""?"<%= user.getCurOrgName()%>":value;
				}},
			{ display: '状态', name:'tmaom_is_valid',width:100, align: 'left' ,render: function(record, index, value, oth){
					return value=="1"?"有效":"无效";
				}
			},
			{ display: '查看', name:'edit',width:50,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/search.gif' onclick='Detail(" + JSON.stringify(record) + ")'></img>";
				}
			}
		],
		toolbar: {
			items: [
				{ text: '新建', click: addData, icon: 'add' },
				{ line: true },
				{ text: '删除', click: delData, icon: 'delete'}
			]
		}	
	});
	
	//明细
	detail = $("#detail").ligerGrid({
		width: '660', height:'325',enabledSort:false,delayLoad:true,
		usePager: false, rownumbers: true, checkbox: true, alternatingRow: true,async:false,
		columns: [
			{ display: 'tmaod_id', name: 'tmaod_id', hide: true,width:1 },
			{ display: 't_tmgd_name', name: 't_tmgd_name', hide: true,width:1 },
			{ display: 't_tmad_name', name: 't_tmad_name', hide: true,width:1 },
			{ display: '药具种类', name: 'tmgd_name', width: 100, align: 'left' },
			{ display: '药品名称', name: 'tmad_name', width: 100, align: 'left' },			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' },
			{ display: '价格', name: 'tmad_price', width: 80, align: 'left' },
			{ display: '数量', name: 'tmaod_num', width: 80, align: 'left' },
			{ display: '金额', name: 'money', width: 80, align: 'left',render: function(record, index, value, oth){
					return formatCurrency(record.tmaod_num * record.tmad_price);
				} 
			},
			{ display: '修改', name:'edit',width:50,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='edit(" + JSON.stringify(record) + ")'></img>";
				}
			}
		],
		toolbar: {
			items: [
				{ text: '新建', click: function(){
					add_dialog==null?"":add_dialog.hide();
					add();
				}, icon: 'add' },
				{ line: true },
				{ text: '删除', click: del,icon: 'delete'}
			]
		}
	});
	
	//查看
	chakan = $("#chakan").ligerGrid({
		url: _url, width: '690', height:'325',enabledSort:false,delayLoad:true,
		usePager: false, rownumbers: true, alternatingRow: true,async:false,
		columns: [
			{ display: '药具种类', name: 'tmgd_name', width: 100, align: 'left' },
			{ display: '药品名称', name: 'tmad_name', width: 150, align: 'left' },			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' },
			{ display: '价格', name: 'tmad_price', width: 100, align: 'left' },
			{ display: '数量', name: 'tmaod_num', width: 100, align: 'left' },
			{ display: '金额', name: 'money', width: 100, align: 'left' ,render: function(record, index, value, oth){
					return formatCurrency(record.tmaod_num * record.tmad_price);
				}
			}
		]
	});
});
/*
*药具名称
*/
function tmad_name_change(value){
	var paramId = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaIncomeAction",
		"methodname": "selectTmaDictionaryById",
		"logicdata": [],
		"extenddata": []
	};
	paramId.logicdata = '[{"tmad_id":"'+value+'"}]';
	callserver(paramId, function(data, satus){
		$("#tmad_price").val(data.tmad_price);
		$("#tmad_batch_code").val(data.tmad_batch_code);
		$("#tmad_qgp").val(data.tmad_qgp);
		$("#tmad_company_name").val(data.tmad_company_name);
		$("#tmad_unit").val(data.tmad_unit);
		$("#tmad_spec").val(data.tmad_spec);
		$("#tmad_description").val(data.tmad_description);
	},function(data, satus){
		warningTip(data.resultrecord);
	});
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaOutcomeAction",
		"methodname": "selectTmaNumById",
		"logicdata": [],
		"extenddata": []
	};
	param.logicdata = '[{"tmad_id":"'+value+'"}]';
	callserver(param, function(data, satus){
		$("#num").val(data.resultrecord);
	},function(data, satus){
		warningTip(data.resultrecord);
	});
}
/*
*药具种类
*/
function tmgd_name_change(value){
	$("#tmad_name").find("option").remove();
	var paramName = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaIncomeAction",
		"methodname": "selectTmaDictionary",
		"logicdata": [],
		"extenddata": []
	};
	paramName.logicdata = '[{"tmgd_id":"'+value+'"}]';
	callserver(paramName, function(data, satus){
		$("#tmad_price").val("");
		$("#tmad_batch_code").val("");
		$("#tmad_qgp").val("");
		$("#tmad_company_name").val("");
		$("#tmad_unit").val("");
		$("#tmad_spec").val("");
		$("#tmad_description").val("");
		$("#tmad_name").append('<option value="">--请选择--</option>');
		$.each(data, function (i, item) {
        	 $("#tmad_name").append('<option value="'+item.tmad_id+'">'+item.tmad_name+'</option>');
        }); 
	},function(data, satus){
		warningTip(data.resultrecord);
	});
}
/*
 * 药品增加
 */
var add_dialog;
function add(){
	document.getElementById('yaoju').reset();
	$("#tmgd_name").find("option").remove();
	$("#tmad_name").find("option").remove();
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaIncomeAction",
		"methodname": "selectTmGeneralDictionary",
		"logicdata": [],
		"extenddata": []
	};
	callserver(param, function(data, satus){
	$("#tmgd_name").append('<option value="">--请选择--</option>');
	$("#tmad_name").append('<option value="">--请选择--</option>');
		$.each(data, function (i, item) {
        	 $("#tmgd_name").append('<option value="'+item.tmgd_id+'">'+item.tmgd_name+'</option>');
        });
	},function(data, satus){
		warningTip(data.resultrecord);
	});
	add_dialog = initWindowByDiv('yaoju-div', '明细增加', 600, 230, save, closeWin);
}
/*
*药品删除
*/
function del(){
	var str = "";
    var rows = detail.getCheckedRows();
    $(rows).each(function (){
    	str += this.tmaod_id + ",";
    });
    str=str.substring(0,str.length-1);
	if(str == ""){
		warningTip('请至少选则一个药品进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？', function (opt) { 			
		if(opt){
			var temp = mingxi;
	    	mingxi = [];
	    	$.each(temp, function (i, item) {
				if(str.indexOf(item.tmaod_id)>=0){
					
				}else{
					mingxi.push({
    					tmaod_id:item.tmaod_id,
    					tmad_id:item.tmad_id,
    					tmaid_num:item.tmaid_num
    				});
				}
	    	});
			detail.deleteSelectedRow(); 
		}
	});
}
/*
 * 修改药品
 */
var edit_dialog;
function edit(r){
	document.getElementById('yaoju').reset();
	tmgd_name_change(r.t_tmgd_name);
	row	= {
		tmaod_id:r.tmaod_id,
		tmgd_name:r.t_tmgd_name,
		tmad_name:r.t_tmad_name,				
		tmaod_num:r.tmaod_num,
		tmad_company_name:r.tmad_company_name,
		tmad_price:r.tmad_price,
		tmad_batch_code:r.tmad_batch_code,
		tmad_unit:r.tmad_unit,
		tmad_spec:r.tmad_spec,
		tmad_description:r.tmad_description,
		tmad_qgp:r.tmad_qgp,
		num:r.num,
		money:parseInt(r.tmaod_num) * parseFloat(r.tmad_price)
	};	
	loadForm("yaoju", row);
	edit_dialog = initWindowByDiv('yaoju', '明细修改', 600, 230, bianji, closeWin);	
}
function bianji(){
	var tmgd_name = $("#tmgd_name").val().trim();
	var tmad_name = $("#tmad_name").val().trim();
	var tmaod_num = $("#tmaod_num").val().trim();
	if('' == tmgd_name){warningTip("药具类型：不能为空"); return;}
	if('' == tmad_name){warningTip("药品名称：不能为空"); return;}
	if('' == tmaod_num){warningTip("数量：不能为空"); return;}
	if(!checkIsNum(tmaod_num)){warningTip("数量：只能是整数"); return;}
	if(fucCheckLength(tmaod_num)>5){warningTip("数量：不能大于5位"); return;}
		var d = getForm("yaoju");
		//得到的JSON			
		var strJSON = d.substring(1,d.length-1);
		//转换后的JSON对象
		var obj = eval( "(" + strJSON + ")" );
		if(parseInt(obj.tmaod_num) > parseInt(obj.num)){
			succMsgTip("出库数量不能大于库存数量");
			return;
		}
		var isChongFu = true;
		var jsonObj = {};
    	jsonObj.Rows = [];
		$.each(detail.getData(), function (i, item) {
			if(obj.tmaod_id==item.tmaod_id){
				if(isChongFu){
				jsonObj.Rows.push({
        			tmaod_id:obj.tmaod_id,
					tmgd_name:$("#tmgd_name").find("option:selected").text(),
					tmad_name:$("#tmad_name").find("option:selected").text(),
					t_tmgd_name:obj.tmgd_name,
					t_tmad_name:obj.tmad_name,				
					tmaod_num:obj.tmaod_num,
					tmad_company_name:obj.tmad_company_name,
					tmad_price:obj.tmad_price,
					tmad_batch_code:obj.tmad_batch_code,
					tmad_unit:obj.tmad_unit,
					tmad_spec:obj.tmad_spec,
					tmad_description:obj.tmad_description,
					tmad_qgp:item.tmad_qgp,
					num:obj.num,
					money:parseInt(obj.tmaod_num) * parseFloat(obj.tmad_price)
        		});
        		isChongFu = false;
				}else{
					succMsgTip("药品"+ tmad_name + "已经在列表中，不能出现重复。");
				}				
			}else{
				jsonObj.Rows.push({
	        		tmaod_id:item.tmaod_id,
					tmgd_name:item.tmgd_name,
					tmad_name:item.tmad_name,
					t_tmgd_name:item.t_tmgd_name,
					t_tmad_name:item.t_tmad_name,				
					tmaod_num:item.tmaod_num,
					tmad_company_name:item.tmad_company_name,
					tmad_price:item.tmad_price,
					tmad_batch_code:item.tmad_batch_code,
					tmad_unit:item.tmad_unit,
					tmad_spec:item.tmad_spec,
					tmad_description:item.tmad_description,
					tmad_qgp:item.tmad_qgp,
					num:item.num,
					money:parseInt(item.tmaod_num) * parseFloat(item.tmad_price)
	        	});
			}
    	});
    	detail.set({ data: jsonObj });
    	var temp = mingxi;
    	mingxi = [];
    	$.each(temp, function (i, item) {
			if(obj.tmaod_id==item.tmaod_id){
				mingxi.push({
		    		tmaod_id:obj.tmaod_id,
		    		tmad_id:obj.tmad_name,
		    		tmaod_num:obj.tmaod_num
		    	});
			}else{
				mingxi.push({
		    		tmaod_id:item.tmaod_id,
		    		tmad_id:item.tmad_id,
		    		tmaod_num:item.tmaod_num
		    	});
			}
    	});
		edit_dialog.hide();
}
function onkeyupNum(v){
	if(0==v.charAt(0)){
		$("#tmaod_num").val("");
	}
}
/*
 * 新建/修改入库信息
 */
function save(){
	tmaod++;
	var tmgd_name = $("#tmgd_name").val().trim();
	var tmad_name = $("#tmad_name").val().trim();
	var tmaod_num = $("#tmaod_num").val().trim();
	if('' == tmgd_name){warningTip("药具类型：不能为空"); return;}
	if('' == tmad_name){warningTip("药品名称：不能为空"); return;}
	if('' == tmaod_num){warningTip("数量：不能为空"); return;}
	if(!checkIsNum(tmaod_num)){warningTip("数量：只能是整数"); return;}
	if(fucCheckLength(tmaod_num)>5){warningTip("数量：不能大于5位"); return;}
		var t = getForm("yaoju");
		//得到的JSON			
		var strJSON = t.substring(1,t.length-1);
		//转换后的JSON对象
		var obj = eval( "(" + strJSON + ")" );
		if(parseInt(obj.tmaod_num) > parseInt(obj.num)){
			warningTip("出库数量不能大于库存数量");
			return;
		}
		var isChongFu = true;
		var jsonObj = {};
    	jsonObj.Rows = [];
		$.each(detail.getData(), function (i, item) {
			if(obj.tmad_name==item.t_tmad_name){
				isChongFu = false;
			}
			jsonObj.Rows.push({
        		tmaod_id:item.tmaod_id,
				tmgd_name:item.tmgd_name,
				tmad_name:item.tmad_name,
				t_tmgd_name:item.t_tmgd_name,
				t_tmad_name:item.t_tmad_name,				
				tmaod_num:item.tmaod_num,
				tmad_company_name:item.tmad_company_name,
				tmad_price:item.tmad_price,
				tmad_batch_code:item.tmad_batch_code,
				tmad_unit:item.tmad_unit,
				tmad_spec:item.tmad_spec,
				tmad_description:item.tmad_description,
				tmad_qgp:item.tmad_qgp,
				num:item.num,
				money:parseInt(item.tmaod_num) * parseFloat(item.tmad_price)
        	});
    	});
    	var tmad_name = $("#tmad_name").find("option:selected").text();
    	var tmgd_name = $("#tmgd_name").find("option:selected").text()
    	if(isChongFu){
    	jsonObj.Rows.push({
			tmaod_id:tmaod,
			tmgd_name:tmgd_name,
			tmad_name:tmad_name,
			t_tmgd_name:obj.tmgd_name,
			t_tmad_name:obj.tmad_name,				
			tmaod_num:obj.tmaod_num,
			tmad_company_name:obj.tmad_company_name,
			tmad_price:obj.tmad_price,
			tmad_batch_code:obj.tmad_batch_code,
			tmad_unit:obj.tmad_unit,
			tmad_spec:obj.tmad_spec,
			tmad_description:obj.tmad_description,
			tmad_qgp:obj.tmad_qgp,
			num:obj.num,
			money:parseInt(obj.tmaod_num) * parseFloat(obj.tmad_price)
		});
		detail.set({ data: jsonObj });
    	mingxi.push({
    		tmaod_id:tmaod,
    		tmad_id:obj.tmad_name,
    		tmaod_num:obj.tmaod_num
    	});
    	add_dialog.hide();
		}else{
		warningTip("药品"+ tmad_name + "可以修改出库数量，不能重复添加。");
		}
}
/*
*查看
*/
function Detail(record){
	$("#d_tmaim_code").val(record.tmaom_code);
	$("#d_tmaim_time").val(record.tmaom_time);
	$("#d_org").val(record.org_id);
	$("#d_tmaom_type").val(record.tmaom_type);
	initWindowByDiv2('chakan-div', '药具出库单查看', 720, 450, closeWin);
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaOutcomeAction",
		"methodname": "detail",
		"logicdata": [],
		"extenddata": []
	};
	param.logicdata = "[{\"tmaom_id\":\""+record.tmaom_id+"\"}]";
	chakan.setOptions({url:_url,parms: param});
}
/*
 * 出库单
 */
 var addData_dialog; 
function addData(){
	document.getElementById('chukudan').reset();
	addData_dialog = initWindowByDiv('chukudan-div', '药具出库单', 690, 475, insert, function(){
		add_dialog==null?"":add_dialog.hide();
		grid==null?"":grid.hide();
		addData_dialog.hide();
	});
	$("#create_by").val(userName);
	mingxi = [];
	tmaod = 0;
	document.getElementById('a1').style.display = "none";
	document.getElementById('a2').innerHTML = '<div align="right"><input type="button" onclick="baofeileixing();" value="报废登记" /><input type="hidden" id="tmaom_type" name="tmaom_type" value="1"/></div>';
	var shijian = getCurDateTime();
	$("#tmaom_time").ligerDateEditor({ showTime: true, width:180});
	$("#tmaom_time").ligerGetDateEditorManager().setValue(shijian.substring(0,shijian.lastIndexOf(":")));
	var nian = shijian.substring(0,shijian.indexOf("-"));
	var yue = shijian.substring(shijian.indexOf("-")+1,shijian.lastIndexOf("-"));
	var tian = shijian.substring(shijian.lastIndexOf("-")+1,shijian.indexOf(" "));
	var xiaoshi = shijian.substring(shijian.lastIndexOf(" ")+1,shijian.indexOf(":"));
	var fenzhong = shijian.substring(shijian.indexOf(":")+1,shijian.lastIndexOf(":"));
	var miao = shijian.substring(shijian.lastIndexOf(":")+1);
	var str = "KM" + nian + yue + tian + xiaoshi + fenzhong + miao;
	var chukubianhaoSize = chukubianhao.length;
	var	intSeq = parseInt(chukubianhao);
	intSeq++;
	var seqSize = (intSeq + "").length;
	var s = "";
	while (chukubianhaoSize - seqSize > 0)
	{
		s += "0";
		chukubianhaoSize--;
	}
	chukubianhao = s + intSeq;
	str = str + s + intSeq;
	$("#tmaom_code").val(str);
	detail.loadData();
	var jsonObj = {};
    jsonObj.Rows = [];
    detail.set({ data: jsonObj });
}

function insert(){
	var tmaom_code = $("#tmaom_code").val().trim();
	var tmaom_time = $("#tmaom_time").val().trim();
	if('' == tmaom_code){warningTip("出库编号：不能为空"); return;}
	if(!checkIsStrNum(tmaom_code)){
		warningTip("出库编号：必须为字母、数字组成");
		return;
	}
	if(fucCheckLength(tmaom_code) > 32){
		warningTip("出库编号：不能超过32字符");
		return;
	}
	if('' == tmaom_time){warningTip("出库日期：不能为空"); return;}
		var param = {
			"classname": "com.wxtf.platform.main.contraceptives.TmaOutcomeAction",
			"methodname": "save",
			"logicdata": [],
			"extenddata": []
		};		
		var data = getForm("chukudan");
		var d = data.substring(0,data.length-2);
		d = d+",ids:"+JSON.stringify(mingxi)+"}]";
		param.logicdata = d;
		callserver(param, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
}

/*
 * 药具删除
 */
function delData(){
	var str = "";
    var rows = manager.getCheckedRows();
    $(rows).each(function (){
    	str += this.tmaom_id + ",";
    });
    str=str.substring(0,str.length-1);
	if(str == ""){
		warningTip('请至少选则一个出库单进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "delete";
			_jsonObj.logicdata = "[{\"ids\":\"" + str + "\"}]";
			callserver(_jsonObj, function(){ reload(); }, function(){});
		}
	});
}
/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	addData_dialog.hide();
	succMsgTip(data.resultrecord);
	reload();
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}
/*
 * 表格刷新
 */
function reload(){
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = "[]";
	manager.loadData();
}
/*
*报废类型
*/
function baofeileixing(){
	document.getElementById('a1').style.display = "block";
	document.getElementById('a2').innerHTML = '<select id="tmaom_type" name="tmaom_type" style=" width: 182px;"><option value="2">使用报废</option><option value="3">库存报废</option><option value="4">过期报废</option></select>';	
}
/*
*查看库存
*/
function chakankucun(){
	grid==null?"":grid.hide();
	grid = initWindowByDiv2('grid', '库存', 585, 380, closeWin);
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaStoreCheckDetailAction",
		"methodname": "selectKuCun",
		"logicdata": [],
		"extenddata": []
	};
	$("#grid").ligerGrid({
		url: _url, parms: param, width: '560', height:'310',enabledSort:false,async:false,
		usePager: false, rownumbers: true, alternatingRow: true,
		columns: [
			{ display: '药具种类', name: 'tmgd_name', width: 120, align: 'left' ,type: 'string'},
			{ display: '药品名称', name: 'tmad_name', width: 100, align: 'left',type: 'string'},			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' ,type: 'string'},
			{ display: '价格', name: 'tmad_price', width: 50, align: 'left' ,type: 'float'},
			{ display: '数量', name: 'num', width: 50, align: 'left', type: 'int'},
			{ display: '金额', name: 'money', width: 80, align: 'left', type: 'float'}
		]
	});
}
function formatCurrency(num)
        {
            if (!num) return "0.00";
            num = num.toString().replace(/\$|\,/g, '');
            if (isNaN(num))
                num = "0.00";
            sign = (num == (num = Math.abs(num)));
            num = Math.floor(num * 100 + 0.50000000001);
            cents = num % 100;
            num = Math.floor(num / 100).toString();
            if (cents < 10)
                cents = "0" + cents;
            for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
                num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
            return (((sign) ? '' : '-') + '' + num + '.' + cents);
        }
</script>
</head>
	<body>
		<div id="manager"></div>
		<div id="chakan-div" style="display: none;">				
				<table class="form_table">
					<tr>
						<td class="form_label">入库编号：</td>
						<td><input disabled="disabled" class="textbg1" id="d_tmaim_code" name="d_tmaim_code"/></td>
						<td class="form_label">入库日期：</td>
						<td><input disabled="disabled" class="textbg1" id="d_tmaim_time" name="d_tmaim_time"/></td>
					</tr>
					<tr>
						<td class="form_label">组织机构：</td>
						<td><input disabled="disabled" class="textbg1" id="d_org" name="d_org"/></td>
						<td class="form_label">类型：</td>
						<td><input disabled="disabled" class="textbg1" id="d_tmaom_type" name="d_tmaom_type"/></td>
					</tr>
					<tr>
						<td colspan="4"><div id="chakan"></div></td>
					</tr>					
				</table>
		</div>
		<div id="chukudan-div" style="display: none;">
			<form id="chukudan" name="chukudan">
			<input type="hidden" id="tmaom_is_valid" name="tmaom_is_valid" value="1"/>
				<table class="form_table">
					<tr>
						<td class="form_label">出库编号：</td>
						<td><input class="textbg1" id="tmaom_code" name="tmaom_code"/></td>
						<td class="form_label">出库日期：</td>
						<td align="center"><input onkeyup="this.value=formatdata(this.value);" id="tmaom_time" name="tmaom_time"/></td>
					</tr>
					<tr>
						<td class="form_label">组织机构：</td>
						<td>
							<select id="org_id" name="org_id" style=" width: 182px;">
								<%=user.getCurSubOrgOptions()%>
							</select>
						</td>
						<td id="a1" style=" display: none;" class="form_label">报废类型：</td>
						<td id="a2"></td>						
					</tr>
					<tr>
						<td class="form_label">录入人：</td>
						<td><input readonly="readonly" class="textbg1" id="create_by" name="create_by" /></td>
						<td align="right"><input type="button" onclick="chakankucun();" value="查看库存"/></td>
						<td><div id="grid"></div></td>
					</tr>
					<tr>
						<td colspan="4"><div id="detail"></div></td>
					</tr>					
				</table>
			</form>
		</div>
		<div id="yaoju-div" style="display: none;">
			<form id="yaoju" name="yaoju">
			<input type="hidden" id="tmaod_id" name="tmaod_id"/>
				<table class="form_table">
					<tr>
						<td class="form_label">药具类型：</td>
						<td>
						<select style=" width: 182px;" id="tmgd_name" name="tmgd_name" onchange="tmgd_name_change(this.value);">
							<option value="">--请选择--</option>
						</select>
						</td>
						<td class="form_label">药品名称：</td>
						<td>
						<select style=" width: 182px;" id="tmad_name" name="tmad_name" onchange="tmad_name_change(this.value);">
							<option value="">--请选择--</option>
						</select>
						</td>
					</tr>
					<tr>
						<td class="form_label">药品描述：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_description" name="tmad_description" value=""/></td>
						<td class="form_label">药品规格：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_spec" name="tmad_spec"  value=""/></td>
					</tr>
					<tr>
						<td class="form_label">药品单位：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_unit" name="tmad_unit" value=""/></td>
						<td class="form_label">生产厂商：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_company_name" name="tmad_company_name" value=""/></td>
					</tr>
					<tr>
						<td class="form_label">保质期：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_qgp" name="tmad_qgp" value=""/></td>
						<td class="form_label">批号：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_batch_code" name="tmad_batch_code" value=""/></td>
					</tr>
					<tr>
						<td class="form_label">价格：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_price" name="tmad_price" value=""/></td>
						<td class="form_label">数量：</td>
						<td><input class="textbg1" id="tmaod_num" name="tmaod_num" onkeyup="onkeyupNum(this.value);"/></td>
					</tr>
					<tr>
						<td colspan="2"></td>
						<td class="form_label">库存数量：</td>
						<td><input readonly="readonly" class="textbg1" id="num" name="num" value=""/></td>
					</tr>					
				</table>
			</form>
		</div>
	</body>
</html>